<?php
class M_khoahoc extends CI_Model{
    public function __construct()
    {
        parent::__construct();
        // Your own constructor code
    }

    public function hienthinganhkhoahocid($id){
        $this->db->select('*');
        $this->db->from('nganh');
        $this->db->join('khoahoc','khoahoc.id_nganh = nganh.id');
        //$this->db->join('baigiang','baigiang.id_khoahoc = khoahoc.id');
        $this->db->where('khoahoc.id_nganh',$id);

        $result = $this->db->get();
        return $result;

        $result->free_result();
    }
      public function select_idkhoahoc()
        {
             $this->db->select('id');
            $this->db->from('khoahoc');
            $result = $this->db->get();
            return $result;
            $result->free_result();
        }
    public function get_select_kh()
        {     
            $this->db->select('*');
            $this->db->from('khoahoc');
            $result = $this->db->get();
            return $result;
            $result->free_result();
        }
     public function dangky_khoahoc($id_khoahoc,$tenhocvien,$ngaydk)
    {     
        
        $data = array(
                'id_khoahoc'     => $id_khoahoc,
                'tenhocvien'     => $tenhocvien,
                'ngay_dk'      => $ngaydk,
            );            
            $result = $this->db->insert('dangky', $data);
            if($result){
                return true;
            }else{
                return false;
            }
            $result->free_result();;
    }
      
}